package org.xdoclet.plugin.hibernate;

import java.util.HashMap;
import java.util.Map;

import org.generama.FreeMarkerTemplateEngine;
import org.generama.QDoxCapableMetadataProvider;
import org.generama.WriterMapper;
import org.generama.defaults.XMLOutputValidator;
import org.xdoclet.plugin.hibernate.qtags.TagLibrary;

import freemarker.ext.beans.BeansWrapper;

public class QueryPlugin extends AbstractHibernateFreemarkerPlugin {

	public QueryPlugin(FreeMarkerTemplateEngine freemarkerTemplateEngine,
			QDoxCapableMetadataProvider metadataProvider,
			WriterMapper writerMapper) {
		super(freemarkerTemplateEngine, metadataProvider, writerMapper);
        setFileregex("\\.java");
        setFilereplace("\\Query.java");
        setMultioutput(true);
        new TagLibrary(metadataProvider);
	}

	public String getDestinationPackage(Object metadata) {
        String originalPackage = metadataProvider.getOriginalPackageName(metadata);
        if(originalPackage == null) {
            return "";
        }
        return originalPackage.substring(0, originalPackage.lastIndexOf(".")) + ".query";
	}
	
	
}
